--
-- Author: shunguo.chen
-- Date: 2016-10-19 17:56:54
--
-- RewardSignRender

local ClassRef = app.mvc.createRenderClass(...)

--data = RewardSignVo
function ClassRef.create(data,node)
	local sprite = ClassRef.extend(node)
	sprite:init(data)
	return sprite
end

function ClassRef:init(data)
	self.super.init(self, data)

	self:setContentSize(self._ui.Panel:getContentSize())
	self._image = self._ui.Image
	self._receiveBtn = self._ui.btn_receive
	self._tlt = self._ui.tlt
	self._text = self._ui.text

	self._receiveBtn:addClickEventListener(handler(self, self._getDayAward))

	self:refresh()
end

function ClassRef:refresh()
	if self._data then
		--路径有待商榷
		self._image:loadTexture(Res.activityIconPath..self._data.iconName)

		self._tlt:setString(string.format(L("lua_code_text_412"),self._data.idx))
		self._text:setString(self._data.des)
		if self._data.haveGet then
			self._receiveBtn:setEnabled(false)
			self._receiveBtn:getChildByName("name"):setString(L("lua_code_text_492"))
		else
			self._receiveBtn:setEnabled(self._data.canGet)
			self._receiveBtn:getChildByName("name"):setString(L("lua_code_text_93"))
		end


		self:setVisible(true)
	else
		self:setVisible(false)
	end
end

function ClassRef:_getDayAward()
	dump("领取奖励"..self._data.idx) --@ignore
end

function ClassRef:onBtnClick(cb)
	self._onBtnClick = cb
end

return ClassRef
